package heima;

import javax.servlet.*;
import java.io.IOException;

public class Demo3 implements Servlet {
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
//        准备一个默认的用户名和密码
        String username = request.getParameter("username");
        String password = request.getParameter("password");
//        处理返回乱码
        response.setContentType("text/html;charset=UTF-8");
        if("zhangsan".equals(username)&&"123456".equals(password)){
            response.getWriter().write("登录成功3");
        }else{
//            System.out.println("登录失败");
            response.getWriter().write("登录失败3");
        }
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}

